/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.shooter;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import java.security.SecureRandom;

/**
 *
 * @author Unni Vemanchery Mana
 */
public class Sky {
    
    private Star star;
    private SpriteBatch starBatch;
    private BitmapFont starFfont;
    private int count = 300;
    private Star[] stars = new Star[count];
    Pixmap pixel ;
    Texture texture;
    
    public Sky(){
      initialize();  
    }
    
    private void initialize(){
      star = new Star();
      star.x = 10;
      star.y = 330;
      starBatch = new SpriteBatch();
      starFfont = new BitmapFont();
      for(int i =0; i<count;i++){
          Star s = new Star();
          s.x = new SecureRandom().nextInt(470);
          s.y = new SecureRandom().nextInt(330);
          stars[i] = s;
      }
      pixel = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
      pixel.setColor(Color.YELLOW);
      texture = new Texture(pixel);
      pixel.dispose();     
      moveStars();
    }
    
    public void moveStars(){
      starBatch.begin();
      for(int i =0; i<count; i++){
          Star s = stars[i];
      if(s.y < 0)s.y = 420;
       //  starFfont.setColor(1.0f,1.0f,1.0f,1.0f);
         //starFfont.draw(starBatch, ".", s.x, s.y);
         //pixel.drawPixel((int)s.x, (int)s.y);
         starBatch.draw(texture, s.x, s.y);
        s.y = s.y - 1.0f;
       // pixel.dispose();
      }
      starBatch.end();
    }
    
    private class Star{
        private float x;
        private float y;
        private int speed = 1;
    }
}
